# coding=utf-8

from django.shortcuts import redirect
from django.http import HttpResponseRedirect


# 登陆检查 ： 如果没有登录 转到登陆页面
def login(func):
    def login_fun(request,*args,**kwargs):
        if request.session.has_key('user_id'):
            return func(request,*args,**kwargs)
        else:
            red = HttpResponseRedirect('/user/login')
            # red = redirect('/user/login')
            red.set_cookie('url',request.get_full_path())
            print request.get_full_path()
            return red
    return login_fun